and a few other places.
wpt->description = m->symbol_DE;
if (m->mps_name != NULL) {
nr = gt_find_icon_number_from_desc(m->mps_name, MAPSOURCE);
- wpt->icon_descr = gt_find_desc_from_icon_number(nr, MAPSOURCE, NULL);
+ wpt->icon_descr = gt_find_desc_from_icon_number(nr, MAPSOURCE);
}
return;
}
}
gbfprintf(fout, "\n");
- if ((wpt->icon_descr != NULL) || (wpt->wpt_flags.proximity) || \
+ if ((!wpt->icon_descr.isNull()) || (wpt->wpt_flags.proximity) || \
(option_icon != NULL)) {
gbfprintf(fout, "w %s,0,0.0,16777215,255,1,7,,%.1f\n",
wpt->icon_descr.isNull() ? "Waypoint" : CSTR(wpt->icon_descr),
switch (index) {
- int categories, dyn;
+ int categories;
struct tm tm;
char* cerr;
case WAYPT__OFS + 2:
wpt->icon_descr = gt_find_desc_from_icon_number(
- atoi(cin), PCX, &dyn);
+ atoi(cin), PCX);
break;
case WAYPT__OFS + 4:
cdata++;
}
if (*cdata == ';') {
- int dyn;
-
cdata++;
wpt->icon_descr = gt_find_desc_from_icon_number(
- atoi(cdata), PCX, &dyn);
+ atoi(cdata), PCX);
}
waypt_add(wpt);
break;
wpt_tmp->icon_descr = d103_symbol_from_icon_number(
way[i]->smbl);
} else {
- int dyn = 0;
wpt_tmp->icon_descr = gt_find_desc_from_icon_number(
- way[i]->smbl, PCX, &dyn);
+ way[i]->smbl, PCX);
}
/*
* If a unit doesn't store altitude info (i.e. a D103)
}
}
-const char*
-gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic)
+const QString
+gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format)
{
- icon_mapping_t* i;
- char custom[] = "Custom 63 ";
-
if ((garmin_format == GDB) && (icon >= 500) && (icon <= 563)) {
- snprintf(custom, sizeof(custom), "Custom %d", icon - 500);
- *dynamic = 1;
- return xstrdup(custom);
+ return QString("Custom %d").arg(icon - 500);
}
if ((garmin_format == PCX) && (icon >= 7680) && (icon <= 8191)) {
- snprintf(custom, sizeof(custom), "Custom %d", icon - 7680);
- *dynamic = 1;
- return xstrdup(custom);
+ return QString("Custom %d").arg(icon - 7680);
}
- if (dynamic) {
- *dynamic = 0;
- }
-
- for (i = garmin_icon_table; i->icon; i++) {
+ for (icon_mapping_t* i = garmin_icon_table; i->icon; i++) {
switch (garmin_format) {
case MAPSOURCE:
case GDB:
typedef enum {MAPSOURCE, PCX, GARMIN_SERIAL, GDB} garmin_formats_e;
-const char* gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic);
+const QString gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format);
int gt_find_icon_number_from_desc(const QString& desc, garmin_formats_e garmin_format);
extern icon_mapping_t garmin_icon_table[];
const char* dspl_mode;
const char* country;
double x;
- int i, icon, dynamic;
- const char* icon_descr;
+ int i, icon;
gmsd = GMSD_FIND(wpt);
if (icon == -1) {
icon = gt_find_icon_number_from_desc(wpt->icon_descr, GDB);
}
- icon_descr = gt_find_desc_from_icon_number(icon, GDB, &dynamic);
- print_string("%s\t", icon_descr);
- if (dynamic) {
- // sleaze alert: cast away constness.
- xfree((char*) icon_descr);
- }
+ print_string("%s\t", gt_find_desc_from_icon_number(icon, GDB));
print_string("%s\t", GMSD_GET(facility, ""));
print_string("%s\t", GMSD_GET(city, ""));
fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
while ((str = csv_lineparse(NULL, "\t", "", column++))) {
- int i, dynamic;
+ int i;
double d;
int field_no = header_fields[waypt_header][column];
case 11:
i = gt_find_icon_number_from_desc(str, GDB);
GMSD_SET(icon, i);
- wpt->icon_descr = gt_find_desc_from_icon_number(i, GDB, &dynamic);
+ wpt->icon_descr = gt_find_desc_from_icon_number(i, GDB);
break;
case 12:
GMSD_SETSTR(facility, str);
read_waypoint(gt_waypt_classes_e* waypt_class_out)
{
char buf[128]; /* used for temporary stuff */
- int display, icon, dynamic;
+ int display, icon;
gt_waypt_classes_e wpt_class;
int i;
Waypoint* res;
GMSD_SETSTR(postal_code, bufp);
}
- res->icon_descr = gt_find_desc_from_icon_number(icon, GDB, &dynamic);
+ res->icon_descr = gt_find_desc_from_icon_number(icon, GDB);
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, icon != GDB_DEF_ICON)
return len;
}
-const char*
+const QString
lowranceusr_find_desc_from_icon_number(const int icon)
{
const lowranceusr_icon_mapping_t* i;
int lat;
int lon;
int icon;
- int dynamic;
Waypoint* thisWaypoint = NULL;
double mps_altitude = unknown_alt;
}
/* might need to change this to handle version dependent icon handling */
- thisWaypoint->icon_descr = gt_find_desc_from_icon_number(icon, MAPSOURCE, &dynamic);
+ thisWaypoint->icon_descr = gt_find_desc_from_icon_number(icon, MAPSOURCE);
/* The following Now done elsewhere since it can be useful to read in and
perhaps not add to the list */
if (*cp != '\0') {
wpt_tmp->description = cp;
}
- wpt_tmp->icon_descr = gt_find_desc_from_icon_number(symnum, PCX, NULL);
+ wpt_tmp->icon_descr = gt_find_desc_from_icon_number(symnum, PCX);
if (read_as_degrees || read_gpsu) {
human_to_dec(tbuf, &lat, &lon, 1);
/* since PsiTrex only deals with Garmins, let's use the "proper" Garmin icon name */
/* convert the PsiTrex name to the number, which is the PCX one; from there to Garmin desc */
garmin_icon_num = psit_find_icon_number_from_desc(psit_current_token);
- thisWaypoint->icon_descr = gt_find_desc_from_icon_number(garmin_icon_num, PCX, NULL);
+ thisWaypoint->icon_descr = gt_find_desc_from_icon_number(garmin_icon_num, PCX);
waypt_add(thisWaypoint);
/* since PsiTrex only deals with Garmins, let's use the "proper" Garmin icon name */
/* convert the PsiTrex name to the number, which is the PCX one; from there to Garmin desc */
garmin_icon_num = psit_find_icon_number_from_desc(psit_current_token);
- thisWaypoint->icon_descr = gt_find_desc_from_icon_number(garmin_icon_num, PCX, NULL);
+ thisWaypoint->icon_descr = gt_find_desc_from_icon_number(garmin_icon_num, PCX);
route_add_wpt(rte_head, thisWaypoint);
{
char hdr[20];
unsigned int rte_datapoints;
- char* rname;
+ QString rname;
Waypoint* testwpt;
time_t uniqueValue = 0;
/* route name */
if (rte->rte_name.isEmpty()) {
- sprintf(hdr, "Route%04x", (unsigned) uniqueValue);
- rname = xstrdup(hdr);
+ rname = QString("Route%1").arg((uint) uniqueValue, 4, 16, QChar('0'));
} else {
- rname = xstrdup(rte->rte_name);
+ rname = rte->rte_name;
}
/* check for psitrex comment sign; replace with '$' */
- while ((c = strchr(rname, '#'))) {
- *c = '$';
- }
+ rname = rname.replace(QChar('#'), QChar('$'));
- gbfprintf(psit_file, "Route: %s\n", rname);
- xfree(rname);
+ gbfputs(QString("Route: %1\n").arg(rname), psit_file);
}
}
{
char hdr[30];
unsigned int trk_datapoints;
- char* tname;
+ QString tname;
Waypoint* testwpt;
time_t uniqueValue = 0;
/* track name */
if (trk->rte_name.isEmpty()) {
- sprintf(hdr, "Track%04x", (unsigned) uniqueValue);
- tname = xstrdup(hdr);
+ tname = QString("Track%1").arg((uint) uniqueValue, 4, 16, QChar('0'));
} else {
- tname = xstrdup(trk->rte_name);
+ tname = trk->rte_name;
}
/* check for psitrex comment sign; replace with '$' */
- while ((c = strchr(tname, '#'))) {
- *c = '$';
- }
-
- gbfprintf(psit_file, "Track: %s\n", tname);
+ tname = tname.replace(QChar('#'), QChar('$'));
- xfree(tname);
+ gbfputs(QString("Track: %1\n").arg(tname), psit_file);
}
}
psit_track_state = 1;
if (global_opts.synthesize_shortnames) {
shortname = mkshort_from_wpt(mkshort_handle, wpt);
} else {
- shortname = xstrdup(wpt->description);
+ shortname = wpt->description;
}
} else {
/* no description available */
- shortname = xstrdup("");
+ shortname = "";
}
} else {
shortname = wpt->shortname;